main: Move GCancellable to toplevel
authorColin Walters <walters@verbum.org>
Tue, 16 Jul 2013 22:13:39 +0000 (18:13 -0400)
committerColin Walters <walters@verbum.org>
Tue, 16 Jul 2013 22:13:39 +0000 (18:13 -0400)
This is just cleaner, and makes the builtins slightly more of a
library, which in turn makes it easier to turn them into real API.

23 files changed:
src/ostree/ot-builtin-admin.c
src/ostree/ot-builtin-cat.c
src/ostree/ot-builtin-checkout.c
src/ostree/ot-builtin-checksum.c
src/ostree/ot-builtin-commit.c
src/ostree/ot-builtin-config.c
src/ostree/ot-builtin-diff.c
src/ostree/ot-builtin-fsck.c
src/ostree/ot-builtin-init.c
src/ostree/ot-builtin-log.c
src/ostree/ot-builtin-ls.c
src/ostree/ot-builtin-prune.c
src/ostree/ot-builtin-pull-local.c
src/ostree/ot-builtin-pull.c
src/ostree/ot-builtin-refs.c
src/ostree/ot-builtin-remote.c
src/ostree/ot-builtin-rev-parse.c
src/ostree/ot-builtin-show.c
src/ostree/ot-builtin-trivial-httpd.c
src/ostree/ot-builtin-write-refs.c
src/ostree/ot-builtins.h
src/ostree/ot-main.c
src/ostree/ot-main.h

index b7b5ead453ea69cbdf73cadd49270927730cea01..46656806ad01116b3e055d4731da01821f472d5a 100644 (file)
@@ -48,10 +48,9 @@ static OstreeAdminCommand admin_subcommands[] = {
 };
 
 gboolean
-ostree_builtin_admin (int argc, char **argv, GFile *repo_path, GError **error)
+ostree_builtin_admin (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
 {
   gboolean ret = FALSE;
-  __attribute__((unused)) GCancellable *cancellable = NULL;
   const char *opt_sysroot = "/";
   const char *subcommand_name;
   OstreeAdminCommand *subcommand;
index 4650ee46dcba28917d51851db4b249b7b19d412d..357878eec2b9d6f74c682614b59fa188697013ea 100644 (file)
@@ -53,12 +53,11 @@ cat_one_file (GFile         *f,
 }
 
 gboolean
-ostree_builtin_cat (int argc, char **argv, GFile *repo_path, GError **error)
+ostree_builtin_cat (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
 {
   GOptionContext *context;
   gboolean ret = FALSE;
   int i;
-  GCancellable *cancellable = NULL;
   const char *rev;
   gs_unref_object OstreeRepo *repo = NULL;
   gs_unref_object GOutputStream *stdout_stream = NULL;
index e2ada0719dfa81d9821856bc985fbb5f5a23b2d8..5691c71bab3d54092188268f884d0ae9df458ad3 100644 (file)
@@ -215,10 +215,9 @@ process_many_checkouts (OstreeRepo         *repo,
 }
 
 gboolean
-ostree_builtin_checkout (int argc, char **argv, GFile *repo_path, GError **error)
+ostree_builtin_checkout (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
 {
   GOptionContext *context;
-  GCancellable *cancellable = NULL;
   gboolean ret = FALSE;
   const char *commit;
   const char *destination;
index 89dc4abe30c1f74635eeb9e47802428c5b4207ab..d18121b12687b9ba7122727c6b9e4e84571510b5 100644 (file)
@@ -53,7 +53,7 @@ on_checksum_received (GObject    *obj,
 }
 
 gboolean
-ostree_builtin_checksum (int argc, char **argv, GFile *repo_path_path, GError **error)
+ostree_builtin_checksum (int argc, char **argv, GFile *repo_path_path, GCancellable *cancellable, GError **error)
 {
   GOptionContext *context;
   gboolean ret = FALSE;
@@ -77,7 +77,7 @@ ostree_builtin_checksum (int argc, char **argv, GFile *repo_path_path, GError **
 
   data.loop = g_main_loop_new (NULL, FALSE);
   data.error = error;
-  ostree_checksum_file_async (f, OSTREE_OBJECT_TYPE_FILE, G_PRIORITY_DEFAULT, NULL, on_checksum_received, &data);
+  ostree_checksum_file_async (f, OSTREE_OBJECT_TYPE_FILE, G_PRIORITY_DEFAULT, cancellable, on_checksum_received, &data);
   
   g_main_loop_run (data.loop);
 
index 805dfcd78d4fdb093d17176cf370c2dc7bed3599..58797ccc4e2ad360b133e71b773b21b24a101c0b 100644 (file)
@@ -208,13 +208,12 @@ commit_filter (OstreeRepo         *self,
 }
 
 gboolean
-ostree_builtin_commit (int argc, char **argv, GFile *repo_path, GError **error)
+ostree_builtin_commit (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
 {
   GOptionContext *context;
   gboolean ret = FALSE;
   gboolean skip_commit = FALSE;
   gboolean in_transaction = FALSE;
-  GCancellable *cancellable = NULL;
   gs_unref_object OstreeRepo *repo = NULL;
   gs_unref_object GFile *arg = NULL;
   gs_free char *parent = NULL;
index 28c26dd11bc7430e92d9c5813a2e4902a36a78b3..eb2766da7a1ff96bcf2a71c9f699133f207bbfc2 100644 (file)
@@ -51,7 +51,7 @@ split_key_string (const char   *k,
 }
 
 gboolean
-ostree_builtin_config (int argc, char **argv, GFile *repo_path, GError **error)
+ostree_builtin_config (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
 {
   GOptionContext *context = NULL;
   gboolean ret = FALSE;
index 484f036914f45f7cd587a59ab1f6f12e502ad473..143fe26aec04ea2011ec6e01084a5547e87cb2dc 100644 (file)
@@ -58,11 +58,10 @@ parse_file_or_commit (OstreeRepo  *repo,
 }
 
 gboolean
-ostree_builtin_diff (int argc, char **argv, GFile *repo_path, GError **error)
+ostree_builtin_diff (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
 {
   gboolean ret = FALSE;
   GOptionContext *context;
-  GCancellable *cancellable = NULL;
   const char *src;
   const char *target;
   gs_unref_object OstreeRepo *repo = NULL;
index fe2b6dfb65a8dbce176dc140a9eab43c20714cbd..77fe7955c5699e51373dcb411c51bc16e1bd5631 100644 (file)
@@ -175,12 +175,11 @@ fsck_reachable_objects_from_commits (OtFsckData            *data,
 }
 
 gboolean
-ostree_builtin_fsck (int argc, char **argv, GFile *repo_path, GError **error)
+ostree_builtin_fsck (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
 {
+  gboolean ret = FALSE;
   GOptionContext *context;
   OtFsckData data;
-  gboolean ret = FALSE;
-  GCancellable *cancellable = NULL;
   GHashTableIter hash_iter;
   gpointer key, value;
   gs_unref_object OstreeRepo *repo = NULL;
index add3aab29030a01e208d2587f93fc0056fd5d945..a992bfbd7ad6acc27d018f9641a2a7b2b5a08630 100644 (file)
@@ -39,11 +39,10 @@ static GOptionEntry options[] = {
 
 
 gboolean
-ostree_builtin_init (int argc, char **argv, GFile *repo_path, GError **error)
+ostree_builtin_init (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
 {
   GOptionContext *context = NULL;
   gboolean ret = FALSE;
-  __attribute__ ((unused)) GCancellable *cancellable = NULL;
   const char *mode_str = "bare";
   gs_unref_object GFile *child = NULL;
   gs_unref_object GFile *grandchild = NULL;
index 638cec808bb40a4bf21e09c0404ac2d7564c767d..a5e9715b2cce56c58a4872fa0cab6e3451225702 100644 (file)
@@ -30,7 +30,7 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ostree_builtin_log (int argc, char **argv, GFile *repo_path, GError **error)
+ostree_builtin_log (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
 {
   GOptionContext *context;
   gboolean ret = FALSE;
index 333d9566e58dfb53adb7a584ea0272f613ac93df..9120277b336b5a7a6ccc15067f142a5679d68349 100644 (file)
@@ -188,7 +188,7 @@ print_directory_recurse (GFile    *f,
 }
 
 gboolean
-ostree_builtin_ls (int argc, char **argv, GFile *repo_path, GError **error)
+ostree_builtin_ls (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
 {
   GOptionContext *context;
   gboolean ret = FALSE;
@@ -216,7 +216,7 @@ ostree_builtin_ls (int argc, char **argv, GFile *repo_path, GError **error)
     }
   rev = argv[1];
 
-  if (!ostree_repo_read_commit (repo, rev, &root, NULL, error))
+  if (!ostree_repo_read_commit (repo, rev, &root, cancellable, error))
     goto out;
 
   for (i = 2; i < argc; i++)
@@ -227,7 +227,7 @@ ostree_builtin_ls (int argc, char **argv, GFile *repo_path, GError **error)
       g_clear_object (&file_info);
       file_info = g_file_query_info (f, OSTREE_GIO_FAST_QUERYINFO,
                                      G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
-                                     NULL, error);
+                                     cancellable, error);
       if (!file_info)
         goto out;
       
index be22f4c191a09afae2ec9fbc3334f3015736cbf2..98fe9d6134e8581ba8c6ede473b7c5aadfa04e6a 100644 (file)
@@ -37,11 +37,10 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ostree_builtin_prune (int argc, char **argv, GFile *repo_path, GError **error)
+ostree_builtin_prune (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
 {
   gboolean ret = FALSE;
   GOptionContext *context;
-  GCancellable *cancellable = NULL;
   gs_unref_object OstreeRepo *repo = NULL;
   gs_free char *formatted_freed_size = NULL;
   OstreeRepoPruneFlags pruneflags = 0;
index da5374ed4495426586a530045b7703122ce0b8bb..d99e2b8b7837f658e94e936f07a85767dc5d5a42 100644 (file)
@@ -161,10 +161,9 @@ idle_print_status (gpointer user_data)
 }
 
 gboolean
-ostree_builtin_pull_local (int argc, char **argv, GFile *repo_path, GError **error)
+ostree_builtin_pull_local (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
 {
   gboolean ret = FALSE;
-  GCancellable *cancellable = NULL;
   GOptionContext *context;
   const char *src_repo_path;
   int i;
index 5753cd87b850765d1fdbac63c9607b53bb41fac4..a860625790c34244c8f4c461d419a8d4b07eafa5 100644 (file)
@@ -33,11 +33,10 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GError **error)
+ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
 {
   GOptionContext *context;
   gboolean ret = FALSE;
-  GCancellable *cancellable = NULL;
   const char *remote;
   OstreeRepoPullFlags pullflags = 0;
   gs_unref_object OstreeRepo *repo = NULL;
index 0c8c751f90f8f66e727d113c597359123eff2a27..eb3e8fcf190726a19b98e7479320b7ff74f98a91 100644 (file)
@@ -33,10 +33,9 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ostree_builtin_refs (int argc, char **argv, GFile *repo_path, GError **error)
+ostree_builtin_refs (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
 {
   gboolean ret = FALSE;
-  GCancellable *cancellable = NULL;
   GOptionContext *context;
   const char *refspec_prefix = NULL;
   gs_unref_object OstreeRepo *repo = NULL;
index 16ecbea1179083f5aaefbea67ecde91be640dba2..5a9964a23b7d3e80391a1e409670dcf44722fab5 100644 (file)
@@ -40,7 +40,7 @@ usage_error (GOptionContext *context, const char *message, GError **error)
 }
 
 gboolean
-ostree_builtin_remote (int argc, char **argv, GFile *repo_path, GError **error)
+ostree_builtin_remote (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
 {
   GOptionContext *context;
   gboolean ret = FALSE;
index c29172cda99f4bd16f8bc65aaaef4c6c1d1006ec..7d6eebdfceba04353682359da8ce174d29f11430 100644 (file)
@@ -30,7 +30,7 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ostree_builtin_rev_parse (int argc, char **argv, GFile *repo_path, GError **error)
+ostree_builtin_rev_parse (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
 {
   GOptionContext *context;
   gboolean ret = FALSE;
index 543672ff021d4cc5138d911759a0ed4a2885aaae..5cddc8973c87ccc9ee6dfa42073e51b4835fd445 100644 (file)
@@ -194,7 +194,7 @@ do_print_metadata_key (OstreeRepo  *repo,
 }
 
 gboolean
-ostree_builtin_show (int argc, char **argv, GFile *repo_path, GError **error)
+ostree_builtin_show (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
 {
   GOptionContext *context;
   gboolean ret = FALSE;
index ac11c72e45be6f9c091a3aa39fd35a6bad374c09..f3bd7cfff7962a04b86ae9a0256f95c5a3cc932a 100644 (file)
@@ -263,10 +263,9 @@ on_dir_changed (GFileMonitor  *mon,
 }
 
 gboolean
-ostree_builtin_trivial_httpd (int argc, char **argv, GFile *repo_path, GError **error)
+ostree_builtin_trivial_httpd (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
 {
   gboolean ret = FALSE;
-  GCancellable *cancellable = NULL;
   GOptionContext *context;
   const char *dirpath;
   OtTrivialHttpd appstruct;
index 01185d8d61479b0547add6e8d9eebad5ab5c1d7c..b7e463b472e2844f331b9444c9ad4f420a257d99 100644 (file)
@@ -33,11 +33,10 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ostree_builtin_write_refs (int argc, char **argv, GFile *repo_path, GError **error)
+ostree_builtin_write_refs (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
 {
   GOptionContext *context;
   gboolean ret = FALSE;
-  GCancellable *cancellable = NULL;
   GError *temp_error = NULL;
   gsize len;
   gs_unref_object OstreeRepo *repo = NULL;
index 6719f0f2182d265cef331e6cdf06f3166f969e85..777a5e7c9ffc3a3a4332082e31cc1025e4c152d9 100644 (file)
 
 G_BEGIN_DECLS
 
-gboolean ostree_builtin_admin (int argc, char **argv, GFile *repo_path, GError **error);
-gboolean ostree_builtin_cat (int argc, char **argv, GFile *repo_path, GError **error);
-gboolean ostree_builtin_config (int argc, char **argv, GFile *repo_path, GError **error);
-gboolean ostree_builtin_checkout (int argc, char **argv, GFile *repo_path, GError **error);
-gboolean ostree_builtin_checksum (int argc, char **argv, GFile *repo_path, GError **error);
-gboolean ostree_builtin_commit (int argc, char **argv, GFile *repo_path, GError **error);
-gboolean ostree_builtin_diff (int argc, char **argv, GFile *repo_path, GError **error);
-gboolean ostree_builtin_init (int argc, char **argv, GFile *repo_path, GError **error);
-gboolean ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GError **error);
-gboolean ostree_builtin_pull_local (int argc, char **argv, GFile *repo_path, GError **error);
-gboolean ostree_builtin_log (int argc, char **argv, GFile *repo_path, GError **error);
-gboolean ostree_builtin_ls (int argc, char **argv, GFile *repo_path, GError **error);
-gboolean ostree_builtin_prune (int argc, char **argv, GFile *repo_path, GError **error);
-gboolean ostree_builtin_refs (int argc, char **argv, GFile *repo_path, GError **error);
-gboolean ostree_builtin_fsck (int argc, char **argv, GFile *repo_path, GError **error);
-gboolean ostree_builtin_show (int argc, char **argv, GFile *repo_path, GError **error);
-gboolean ostree_builtin_rev_parse (int argc, char **argv, GFile *repo_path, GError **error);
-gboolean ostree_builtin_remote (int argc, char **argv, GFile *repo_path, GError **error);
-gboolean ostree_builtin_write_refs (int argc, char **argv, GFile *repo_path, GError **error);
-gboolean ostree_builtin_trivial_httpd (int argc, char **argv, GFile *repo_path, GError **error);
+gboolean ostree_builtin_admin (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
+gboolean ostree_builtin_cat (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
+gboolean ostree_builtin_config (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
+gboolean ostree_builtin_checkout (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
+gboolean ostree_builtin_checksum (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
+gboolean ostree_builtin_commit (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
+gboolean ostree_builtin_diff (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
+gboolean ostree_builtin_init (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
+gboolean ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
+gboolean ostree_builtin_pull_local (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
+gboolean ostree_builtin_log (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
+gboolean ostree_builtin_ls (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
+gboolean ostree_builtin_prune (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
+gboolean ostree_builtin_refs (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
+gboolean ostree_builtin_fsck (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
+gboolean ostree_builtin_show (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
+gboolean ostree_builtin_rev_parse (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
+gboolean ostree_builtin_remote (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
+gboolean ostree_builtin_write_refs (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
+gboolean ostree_builtin_trivial_httpd (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
 
 G_END_DECLS
 
index 97bac2c28a988baea9759694ce39f894db40786c..1470860aa76c7c14459718dc343bbf1274a49dcc 100644 (file)
@@ -82,6 +82,7 @@ ostree_run (int    argc,
 {
   OstreeCommand *command;
   GError *error = NULL;
+  GCancellable *cancellable = NULL;
   int cmd_argc;
   char **cmd_argv = NULL;
   gboolean have_repo_arg;
@@ -155,7 +156,7 @@ ostree_run (int    argc,
   
   ostree_prep_builtin_argv (cmd, argc-arg_off, argv+arg_off, &cmd_argc, &cmd_argv);
 
-  if (!command->fn (cmd_argc, cmd_argv, repo_file, &error))
+  if (!command->fn (cmd_argc, cmd_argv, repo_file, cancellable, &error))
     goto out;
 
  out:
index c7981b508f9dc1cf9b3100fed7704ecd15379e67..b314f8ffb188deb64ea4a9f311eefc01d7182bd5 100644 (file)
@@ -31,7 +31,7 @@ typedef enum {
 
 typedef struct {
   const char *name;
-  gboolean (*fn) (int argc, char **argv, GFile *repo_path, GError **error);
+  gboolean (*fn) (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
   int flags; /* OstreeBuiltinFlags */
 } OstreeCommand;